package com.bt.controller;

import com.bt.entity.Product;
import com.bt.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class ProductController {

    @Autowired
    private ProductService productService;

    @RequestMapping("/getproduct")
    public String listProducts(Model model) {
        List<Product> productList = productService.getProduct();
        model.addAttribute("productList",productList);
        return "product"; // the html file name
    }

}
